home *** CD-ROM | disk | FTP | other *** search
/ World of Video / World of Video.iso / gfxprograms / 3dprograms / rayshade-4.0 / fixes / fix020 / libshade / lex.l next >
Text File  |  1995-02-13  |  5KB  |  218 lines

  1. /* lex.l                                   */
  2. /* Copyright (C) 1989, 1991, Craig E. Kolb                   */
  3. /* All rights reserved.                               */
  4. /*                                       */
  5. /* This software may be freely copied, modified, and redistributed,       */
  6. /* provided that this copyright notice is preserved on all copies.       */
  7. /*                                       */
  8. /* You may not distribute this software, in whole or in part, as part of   */
  9. /* any commercial product without the express consent of the authors.       */
  10. /*                                        */
  11. /* There is no warranty or other guarantee of fitness of this software       */
  12. /* for any purpose.  It is provided solely "as is".               */
  13. /*                                       */
  14. /* lex.l,v 4.1 1994/08/09 07:45:41 explorer Exp */
  15. %{
  16. #include "config.h"
  17. #include "rayshade.h"
  18. #ifdef I_STRING
  19. #include <string.h>
  20. #else
  21. #include <strings.h>
  22. #endif
  23. #include "liblight/light.h"
  24. #include "libsurf/atmosphere.h"
  25. #include "libsurf/surface.h"
  26. #include "libtext/texture.h"
  27. #include "libobj/geom.h"
  28. #include "symtab.h"
  29. #include "y.tab.h"
  30. extern char *strsave();
  31. %}
  32. alpha    [a-zA-Z]
  33. special    [\.\_-]
  34. digit    [0-9]
  35. exp    [Ee][-+]?{digit}+
  36. string    {alpha}({alpha}|{digit}|{special})*
  37. filename "/"?"/"?(("."|".."|{string})"/")*{string}
  38. %p 9400
  39. %e 1500
  40. %n 600
  41. %%
  42. [ \t\n]            ;
  43. ^#            handlehash();
  44. "/*"            skipcomments();
  45. ambient            return tAMBIENT;
  46. aperture        return tAPERTURE;
  47. applysurf        return tAPPLYSURF;
  48. area            return tAREA;
  49. atmosphere        return tATMOSPHERE;
  50. background        return tBACKGROUND;
  51. blob            return tBLOB;
  52. blotch            return tBLOTCH;
  53. body            return tBODY;
  54. box            return tBOX;
  55. bump            return tBUMP;
  56. checker            return tCHECKER;
  57. cloud            return tCLOUD;
  58. cone            return tCONE;
  59. component        return tCOMPONENT;
  60. contrast        return tCONTRAST;
  61. crop            return tCROP;
  62. cursurf            return tCURSURF;
  63. cutoff            return tCUTOFF;
  64. cylinder        return tCYL;
  65. cylindrical        return tCYLINDRICAL;
  66. define            return tDEFINE;
  67. diffuse            return tDIFFUSE;
  68. difference        return tDIFFERENCE;
  69. directional        return tDIRECTIONAL;
  70. disc            return tDISC;
  71. end            return tEND;
  72. extended        return tEXTENDED;
  73. extinct            return tEXTINCT;
  74. eyep            return tEYEP;
  75. eyesep            return tEYESEP;
  76. filter            return tFILTER;
  77. fbm            return tFBM;
  78. fbmbump            return tFBMBUMP;
  79. flame                   return tFLAME;
  80. focaldist        return tFOCALDIST;
  81. fog            return tFOG;
  82. fogdeck            return tFOGDECK;
  83. fov            return tFOV;
  84. framelength        return tFRAMELENGTH;
  85. frames            return tFRAMES;
  86. gauss            return tGAUSS;
  87. gloss            return tGLOSS;
  88. grid            return tGRID;
  89. heightfield        return tHEIGHTFIELD;
  90. image            return tIMAGE;
  91. index            return tINDEX;
  92. intersect        return tINTERSECT;
  93. jitter            return tJITTER;
  94. light            return tLIGHT;
  95. list            return tLIST;
  96. lookp            return tLOOKP;
  97. map            return tMAP;
  98. marble            return tMARBLE;
  99. maxdepth        return tMAXDEPTH;
  100. mount            return tMOUNT;
  101. mist            return tMIST;
  102. name            return tNAME;
  103. nojitter        return tNOJITTER;
  104. noshadow        return tNOSHADOW;
  105. object            return tOBJECT;
  106. outfile            return tOUTFILE;
  107. plane            return tPLANE;
  108. planar            return tPLANAR;
  109. point            return tPOINT;
  110. poly            return tPOLY;
  111. polygon            return tPOLY;
  112. print            return tPRINT;
  113. quiet            return tQUIET;
  114. range            return tRANGE;
  115. reflect            return tREFLECT;
  116. reflective        return tREFLECT;
  117. report            return tREPORT;
  118. resolution        return tSCREEN; /* A synonym for screen */
  119. rotate            return tROTATE;
  120. sample            return tSAMPLE;
  121. scale            return tSCALE;
  122. screen            return tSCREEN;
  123. shadowtransp        return tSHADOWTRANSP;
  124. shutter            return tSHUTTER;
  125. sky            return tSKY;
  126. smooth            return tSMOOTH;
  127. sphere            return tSPHERE;
  128. spherical        return tSPHERICAL;
  129. specular        return tSPECULAR;
  130. specpow            return tSPECPOW;
  131. spot            return tSPOT;
  132. starttime        return tSTARTTIME;
  133. stripe            return tSTRIPE;
  134. surface            return tSURFACE;
  135. textsurf        return tTEXTSURF;
  136. texture            return tTEXTURE;
  137. tile            return tTILE;
  138. torus            return tTORUS;
  139. transform        return tTRANSFORM;
  140. translate        return tTRANSLATE;
  141. translu            return tTRANSLU;
  142. translucency        return tTRANSLU;
  143. transp            return tTRANSP;
  144. transparent        return tTRANSP;
  145. triangle        return tTRIANGLE;
  146. triangleuv        return tTRIANGLEUV;
  147. union            return tUNION;
  148. up            return tUP;
  149. uv            return tUV;
  150. verbose            return tVERBOSE;
  151. window            return tWINDOW;
  152. windy            return tWINDY;
  153. wood            return tWOOD;
  154. {digit}+ |
  155. {digit}+"."{digit}*({exp})? |
  156. {digit}*"."{digit}+({exp})? |
  157. {digit}+{exp}        {yylval.d = atof(yytext); return tFLOAT;}
  158. {string}        {yylval.c = strsave(yytext); return tSTRING;}
  159. {filename}        {yylval.c = strsave(yytext); return tFILENAME;}
  160. .            return yytext[0];
  161.  
  162. %%
  163. yywrap() {return 1;}
  164. /*
  165.  * Skip over comments.
  166.  */
  167. skipcomments()
  168. {
  169.     char c;
  170.  
  171.     while (1) {
  172.         while (input() != '*')
  173.             ;
  174.         if ((c = input()) == '/')
  175.             return;
  176.         unput(c);
  177.     }
  178. }
  179. /*
  180.  * Deal with ccp-produced lines of the form:
  181.  * # n "filename"
  182.  * and
  183.  * # n
  184.  * Where filename is the name of the file being processed, and n is
  185.  * the current line number in that file.
  186.  */
  187. handlehash()
  188. {
  189.     char buf[BUFSIZ];
  190.     int i;
  191.     extern int yylineno;
  192.     extern char yyfilename[];
  193.  
  194.     /*
  195.      * Read the entire line into buf.
  196.      */
  197.     for (i = 0; (buf[i] = input()) != '\n'; i++)
  198.             ;
  199.     unput(buf[i]);        /* To make sure consecutive # lines work. */
  200.     buf[i] = (char)NULL;    /* Replace newline with NULL. */
  201.  
  202.     /*
  203.      * Complain if the line was not of the form #n "filename"
  204.      */
  205.     if ((i = sscanf(buf,"%d \"%[^\"]s\"", &yylineno, yyfilename)) == 0 &&
  206.         (i = sscanf(buf," line %d \"%[^\"]s\"",&yylineno,yyfilename))==0) {
  207.         RLerror(RL_PANIC, "Unknown '#' control (%s).\n",buf);
  208.         exit(1);
  209.     }
  210.     if (i == 1 && (index(buf,'"') != (char *)NULL)) {
  211.         /*
  212.          * Filename was given as ""
  213.          */
  214.         (void)strcpy(yyfilename, "stdin");
  215.     }
  216.     yylineno--;  /* The newline we unput will increment yylineno */
  217. }
  218.